<?php

require_once 'cf/db.php';
require_once 'cf/user.php';

$uid = cf\User::register('test','test','Сотрудник');



cf\execQuery("

INSERT INTO cf_page (code,name,menu_name) VALUES('cursy','Курсы обучения','Курсы обучения');
INSERT INTO cf_page (code,name,menu_name) VALUES('cooperation','Сотрудничество','Сотрудничество');
INSERT INTO cf_page (code,name,menu_name) VALUES('representatives','Наши представители','Наши представители');
INSERT INTO cf_page (code,name,menu_name) VALUES('actions','Акции','Акции');

INSERT INTO cf_page (code,name,menu_name) VALUES('delivery','Доставка','Доставка');
INSERT INTO cf_page (code,name,menu_name) VALUES('pay','Способы оплаты','Способы оплаты');
INSERT INTO cf_page (code,name,menu_name) VALUES('contacts','Контакты','Контакты');

INSERT INTO cf_page (code,name,menu_name) VALUES('giftcards','Дисконтные карты','Дисконтные карты');
INSERT INTO cf_page (code,name,menu_name) VALUES('dealers','Дилерам','Дилерам');
INSERT INTO cf_page (code,name,menu_name) VALUES('wholesale','Оптовикам','Оптовикам');
INSERT INTO cf_page (code,name,menu_name) VALUES('to_cooperation','К сотрудничеству','К сотрудничеству');
INSERT INTO cf_page (code,name,menu_name) VALUES('suggestions','Ваши предложения','Ваши предложения');





INSERT INTO cf_groups (name,code,sort_order,hidden) VALUES('Новинки','new',10,1);
INSERT INTO cf_groups (name,code,sort_order,hidden) VALUES('Хиты продаж','hits',20,1);
INSERT INTO cf_groups (name,code,sort_order,hidden) VALUES('Распродажа','sale',30,1);



INSERT INTO cf_groups (name,sort_order) VALUES('Делюкс',100);
	SET @GID = LAST_INSERT_ID();
	INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID,'UV ГЕЛЬ',100);
	INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID,'ШЕЛЛАК',200);
		SET @GID1 = LAST_INSERT_ID();
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'DuoLacquer  BASE',100);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Лак-гель \"DUOLACQUR\"',200);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'DuoLacquer UV TOP COAT',00);
	INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID,'Подготовительные жидкости',300);	
	INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID,'Средства по уходу за ногтями',400);	
		SET @GID1 = LAST_INSERT_ID();
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Базовое покрытие под лак  Dual hardener',100);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Средство для слоящихся ногтей с кальцием Calcium milk enamel',200);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Мультиактивный укрепитель Bio Vitamin booster',300);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Кислородный активатор роста  Oxygen opti grow',400);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Средство с  эффектом мокрого покрытия GLOSS UP',500);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Лечение и предотвращение грибка на ногтях рук и ног.  Hide and treat anti-fungal',600);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Быстросохнущее защитное покрытиеTop shine',700);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Супер средство для удаления кутикулы Good bye cuticles',800);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Мгновенная сушка-капляDrop dry  ',900);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Масло для кутикулы Манго Super cuticle oil',1000);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Масло для кутикулы Абрикосовая косточка Super cuticle oil',1100);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Масло для кутикулы  Мята Super cuticle oil',1200);


INSERT INTO cf_groups (name,sort_order) VALUES('Гель & Акрил',200);
	SET @GID = LAST_INSERT_ID();
	INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID,'Гелевая технология DJ',100);
		SET @GID1 = LAST_INSERT_ID();
		INSERT INTO cf_groups (parent_id,name,sort_order,short_descr,image) VALUES(@GID1,'Прозрачный супер стик гель',100,'Верхнее защитное покрытие, придающее блеск искусственным ногтям.','images/img28.jpg');
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Камуфлирующий (бежевый) Лайт Топаз Light Topaz',200);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Камуфлирующий розовый  гель Топаз  Topaz',300);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Молочно-розовый конструирующий гель Опал  Opal',400);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Белый гель-лак Белый кварц White quartz',500);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Глянцевый финиш гель Сапфир Sapphir',600);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'MOO N STON',700);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Белый гель- лак Белый кварц AQUA MARINA',800);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Защитное покрытие ТОП КОАТ ',900);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Hich tech праймер ',1000);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Грунтовочная ультрасцепка',1100);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'База гель ',1200);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Глянцевый финиш гель  без липкого слоя',1300);
		
	INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID,'Био Гели DJ',200);
		SET @GID1 = LAST_INSERT_ID();
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'БИО-Финиш гель BIO-Finish Gel',100);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Био - Гель прозрачный   NARTSYS',200);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Био - Гель камуфлирующий  AZALEA',300);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Био - Гель молочный белый  LILY',400);
		
	INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID,'Цветные гели DJ',300);
		SET @GID1 = LAST_INSERT_ID();
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Цветные гели-лаки',100);
		
	INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID,'Термогели DJ',400);
		SET @GID1 = LAST_INSERT_ID();
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Термогели',100);

	INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID,'Акриловая технология DJ',500);
		SET @GID1 = LAST_INSERT_ID();
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Акриловая пудра',100);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Мономер',200);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Nail Prep Обезжириватель',300);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'UV Top coat  Защитное покрытие от УФ лучей',400);
		
	INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID,'New French gel',600);
		SET @GID1 = LAST_INSERT_ID();
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Конструирующий (густой) белый гель Bella white',100);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Скульптурный (белый) гель Snow white',200);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Белый гель (средней вязкости) Ultra White',300);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Эластичный цветной гель Natural White',400);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Камуфляжный гель (матово-бежевый) Peach Pink',500);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Камуфляжный гель (матово-розовый) Cover Pink',600);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Конструирующий прозрачный гель (густой) ',700);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Preium Lux Clear',800);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Закрепляющий гель Thin Top Gel',900);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Топ-гель (попупрозрачный розовый) Pink Pearl',1000);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Топ-гель (попупрозрачный бежевый) ',1100);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Natural Heaven',1200);
		INSERT INTO cf_groups (parent_id,name,sort_order) VALUES(@GID1,'Жидкий гель (ярко-белый) Mega White',1300);
		

INSERT INTO cf_groups (name,sort_order) VALUES('Лак & Уход',300);
INSERT INTO cf_groups (name,sort_order) VALUES('Пилки & Кисти',400);
INSERT INTO cf_groups (name,sort_order) VALUES('Формы & Типсы',500);
INSERT INTO cf_groups (name,sort_order) VALUES('Дизайн',600);
INSERT INTO cf_groups (name,sort_order) VALUES('Маникюр & Педикюр',700);
INSERT INTO cf_groups (name,sort_order) VALUES('Депиляция',800);
INSERT INTO cf_groups (name,sort_order) VALUES('Парафин',900);
INSERT INTO cf_groups (name,sort_order) VALUES('Oборудование',1000);
INSERT INTO cf_groups (name,sort_order) VALUES('Ресницы',1100);
INSERT INTO cf_groups (name,sort_order) VALUES('Косметика',1200);
INSERT INTO cf_groups (name,sort_order) VALUES('Для парикмахера',1300);
INSERT INTO cf_groups (name,sort_order) VALUES('Прочее',1400);




INSERT INTO cf_roles (id,name) VALUES('manager','Сотрудники');
INSERT INTO cf_user_roles (role_id,user_id) VALUES('manager',$uid);

INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','pages',1);
INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','groups',1);
INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','products',1);
INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','manufacturers',1);
INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','products_in_group',1);
INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','related_products',1);
INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','order_states',1);
INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','orders',1);
INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','gallery',1);
INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','gallery_albums',1);
INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','gallery_images',1);
INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','gallery_image_in_album',1);


INSERT INTO cf_roles (id,name) VALUES('customer','Покупатели');









INSERT INTO cf_gallery_albums (code,parent_id,name,sort_order,hidden) VALUES('banners',NULL,'Баннеры',10,1);
SET @AID = LAST_INSERT_ID();

INSERT INTO cf_gallery_albums (code,parent_id,name,sort_order) VALUES('banners_left',@AID,'Баннеры справа',1);
	SET @AID = LAST_INSERT_ID();
	INSERT INTO cf_gallery_albums (code,parent_id,name,sort_order) VALUES('gallery1',@AID,'Галерея 1',10);
	INSERT INTO cf_gallery_albums (code,parent_id,name,sort_order) VALUES('gallery2',@AID,'Галерея 2',20);
	INSERT INTO cf_gallery_albums (code,parent_id,name,sort_order) VALUES('gallery3',@AID,'Галерея 3',30);
	INSERT INTO cf_gallery_albums (code,parent_id,name,sort_order) VALUES('gallery4',@AID,'Галерея 4',40);
	INSERT INTO cf_gallery_albums (code,parent_id,name,sort_order) VALUES('gallery5',@AID,'Галерея 5',50);
	INSERT INTO cf_gallery_albums (code,parent_id,name,sort_order) VALUES('gallery6',@AID,'Галерея 6',60);
	
INSERT INTO cf_gallery_albums (parent_id,name,sort_order) VALUES(NULL,'Ногтевой сервис',10);
INSERT INTO cf_gallery_albums (parent_id,name,sort_order) VALUES(NULL,'Наращивание ресниц',20);
INSERT INTO cf_gallery_albums (parent_id,name,sort_order) VALUES(NULL,'Парикмахерское искусство',30);
INSERT INTO cf_gallery_albums (parent_id,name,sort_order) VALUES(NULL,'Работы учеников',40);





CREATE TABLE delivery_price (
	id     INTEGER UNSIGNED  NOT NULL  AUTO_INCREMENT,
	city   VARCHAR(256)      NOT NULL,
	price  VARCHAR(64)       NOT NULL,
	
	PRIMARY KEY (id)
);


INSERT INTO cf_admin_view (
	id, 
	name,
	primary_key_field, 
	name_field,
	query
)
VALUES (
	'delivery_prices',
	'Доставка',
	'id',
	'city',
	'delivery_price'
);
INSERT INTO cf_admin_view_field (view_id,name,title,type_id,sort_order) VALUES ('delivery_prices','id',			'ID',   	'integer',  10);
INSERT INTO cf_admin_view_field (view_id,name,title,type_id,sort_order) VALUES ('delivery_prices','city',		'Город',	'string',   20);
INSERT INTO cf_admin_view_field (view_id,name,title,type_id,sort_order) VALUES ('delivery_prices','price',		'Цена',		'string',   30);


INSERT INTO cf_admin_action_params (
	id, 
	query
) VALUES (
	'delivery_price_edit',
	'SELECT * FROM delivery_price WHERE id=:id'
);
INSERT INTO cf_admin_action_param (params_id,name,type_id,title,mandatory,max_length,sort_order) VALUES ('delivery_price_edit','city', 'String','Город',1,1024,10);
INSERT INTO cf_admin_action_param (params_id,name,type_id,title,mandatory,max_length,sort_order) VALUES ('delivery_price_edit','price','Integer','Цена',1,  64,20);


INSERT INTO cf_admin_action (
	id,
	name,
	query,
	params_id
)
VALUES (
	'delivery_price_edit',
	'Редактирование',
	'UPDATE delivery_price SET city=:city, price=:price WHERE id=:id',
	'delivery_price_edit'
);

INSERT INTO cf_admin_action (
	id,
	name,
	query,
	params_id
)
VALUES (
	'delivery_price_add',
	'Добавить',
	'INSERT INTO delivery_price (city,price) VALUES (:city,:price)',
	'delivery_price_edit'
);


INSERT INTO cf_admin_action (
	id,
	name,
	query
)
VALUES (
	'delivery_price_del',
	'Удаление',
	'DELETE FROM delivery_price WHERE id=:id'
);

INSERT INTO cf_admin_view_action (view_id, action_id, sort_order) VALUES ('delivery_prices', 'delivery_price_edit', 1);
INSERT INTO cf_admin_view_action (view_id, action_id, sort_order) VALUES ('delivery_prices', 'delivery_price_add',  2);
INSERT INTO cf_admin_view_action (view_id, action_id, sort_order) VALUES ('delivery_prices', 'delivery_price_del',  3);



INSERT INTO cf_admin_categories (
	id, 
	parent_id, 
	name, 
	list_id,
	sort_order
)
VALUES (
	'delivery_price',
	NULL,
	'Доставка',
	'delivery_prices',
	10000
);


INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','delivery_prices',1);





INSERT INTO cf_news_categories (code,name) VALUES('news','Новости');
INSERT INTO cf_news_categories (code,name) VALUES('exhibitions','Выставки');

INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','news',1);
INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','news_categories',1);
INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','news_in_category',1);






ALTER TABLE cf_groups ADD column video TEXT;
INSERT INTO cf_admin_action_param (params_id,name,type_id,title,mandatory,max_length,sort_order) VALUES ('group_edit','video','LongString','Видео',0,2048,51);
INSERT INTO cf_admin_action_param (params_id,name,type_id,title,mandatory,max_length,sort_order) VALUES ('group_add','video','LongString','Видео',0,2048,51);
UPDATE cf_admin_action 
SET query='UPDATE cf_groups SET name=:name, code=:code, parent_id=:parent_id, descr=:descr, short_descr=:short_descr, image=:image, video=:video, hidden=:hidden, sort_order=:sort_order, page_title=:page_title, page_keywords=:page_keywords, page_descr=:page_descr WHERE id=:id' 
WHERE id='group_edit';

UPDATE cf_admin_action 
SET query='INSERT INTO cf_groups (name,code,parent_id,descr,short_descr,image,video,hidden,sort_order,page_title,page_keywords,page_descr) VALUES(:name,:code,:parent_id,:descr,:short_descr,:image,:video,:hidden,:sort_order,:page_title,:page_keywords,:page_descr)' 
WHERE id='group_add';



ALTER TABLE cf_products ADD column video TEXT;
INSERT INTO cf_admin_action_param (params_id,name,type_id,title,mandatory,max_length,sort_order) VALUES ('product_edit','video','LongString','Видео',0,4096,492);
INSERT INTO cf_admin_action_param (params_id,name,type_id,title,mandatory,max_length,sort_order) VALUES ('product_add','video','LongString','Видео',0,4096,492);


UPDATE cf_admin_action 
SET query='UPDATE cf_products SET 
        code=:code, 
		manufacturer_id=:manufacturer_id, 
		name=:name, 
		model=:model, 
		short_descr=:short_descr, 
		full_descr=:full_descr, 
		price=:price, 
		discount=:discount, 
		state_id=:state_id, 
		enabled_from=:enabled_from, 
		enabled_to=:enabled_to, 
		tags=:tags,
		article=:article,
		tag_title=:tag_title,
		tag_meta_keywords=:tag_meta_keywords,
		tag_meta_descr=:tag_meta_descr,
		video=:video,
		image1=:image1, image1_text=:image1_text, image2=:image2, image2_text=:image2_text, image3=:image3, image3_text=:image3_text, image4=:image4, image4_text=:image4_text, image5=:image5, image5_text=:image5_text, 
		image6=:image6, image6_text=:image6_text, image7=:image7, image7_text=:image7_text, image8=:image8, image8_text=:image8_text, image9=:image9, image9_text=:image9_text, image10=:image10, image10_text=:image10_text,
		image11=:image11, image11_text=:image11_text, image12=:image12, image12_text=:image12_text, image13=:image13, image13_text=:image13_text, image14=:image14, image14_text=:image14_text, image15=:image15, image15_text=:image15_text
	WHERE id=:id' 
WHERE id='product_edit';

UPDATE cf_admin_action 
SET query='INSERT INTO cf_products (
	    code,
	    manufacturer_id,
		name,
		model,
		short_descr,
		full_descr,
		price,
		discount,
		state_id, 
		enabled_from, 
		enabled_to, 
		tags,
		article,
		video,
		tag_title,
		tag_meta_keywords,
		tag_meta_descr,
		image1, image1_text, image2, image2_text, image3, image3_text, image4, image4_text, image5, image5_text, image6, image6_text, image7, image7_text, 
		image8, image8_text, image9, image9_text, image10, image10_text, image11, image11_text, image12, image12_text, image13, image13_text, image14, image14_text, image15, image15_text
	) VALUES(
		:code,
	    :manufacturer_id,
		:name,
		:model,
		:short_descr,
		:full_descr,
		:price,
		:discount,
		:state_id, 
		:enabled_from, 
		:enabled_to, 
		:tags,
		:article,
		:video,
		:tag_title,
		:tag_meta_keywords,
		:tag_meta_descr,
		:image1, :image1_text, :image2, :image2_text, :image3, :image3_text, :image4, :image4_text, :image5, :image5_text, :image6, :image6_text, :image7, :image7_text, 
		:image8, :image8_text, :image9, :image9_text, :image10, :image10_text, :image11, :image11_text, :image12, :image12_text, :image13, :image13_text, :image14, :image14_text, :image15, :image15_text
	)' 
WHERE id='product_add';






CREATE TABLE promobox (
	id         INTEGER UNSIGNED  NOT NULL  AUTO_INCREMENT,
	name       VARCHAR(1024)     NOT NULL,
	image      VARCHAR(1024)     NOT NULL,
	link       VARCHAR(1024),
	group_id   INTEGER UNSIGNED  NOT NULL,
	
	PRIMARY KEY (id),
	FOREIGN KEY (group_id) REFERENCES cf_groups (id)
) ENGINE=MyISAM;

INSERT INTO cf_admin_view (
	id, 
	name,
	primary_key_field, 
	name_field,
	query
)
VALUES (
	'promobox',
	'Promobox-ы',
	'id',
	'name',
	'SELECT promobox.id AS id,promobox.name AS name,link,promobox.image AS image,cf_groups.name AS group_name FROM promobox INNER JOIN cf_groups ON promobox.group_id=cf_groups.id'
);
INSERT INTO cf_admin_view_field (view_id,name,title,type_id,sort_order) VALUES ('promobox','name',		  'Название',	    'string',  10);
INSERT INTO cf_admin_view_field (view_id,name,title,type_id,sort_order) VALUES ('promobox','image',		  'Изображение',	'image',   20);
INSERT INTO cf_admin_view_field (view_id,name,title,type_id,sort_order) VALUES ('promobox','group_name',  'Категория',	    'string',  30);
INSERT INTO cf_role_view_grants (role_id,view_id,can_read) VALUES('manager','promobox',1);

INSERT INTO cf_admin_action_params (
	id, 
	query
) VALUES (
	'promobox_edit',
	'SELECT * FROM promobox WHERE id=:id'
);
INSERT INTO cf_admin_action_param (params_id,name,type_id,title,mandatory,max_length,sort_order)         VALUES('promobox_edit','name','String','Название',1,1024,10);
INSERT INTO cf_admin_action_param (params_id,name,type_id,title,mandatory,max_length,sort_order,fmt)     VALUES('promobox_edit','image','File','Изображение',0,0,20,'promobox_images;jpg,gif,png');
INSERT INTO cf_admin_action_param (params_id,name,type_id,title,mandatory,max_length,sort_order)         VALUES('promobox_edit','link','String','Ссылка',0,1024,30);
INSERT INTO cf_admin_action_param (params_id,name,type_id,title,mandatory,max_length,sort_order,tree_id) VALUES('promobox_edit','group_id','Integer','Категория',1,10,40,'groups');

INSERT INTO cf_admin_action (
	id,
	name,
	query,
	params_id
)
VALUES (
	'promobox_edit',
	'Редактирование',
	'UPDATE promobox SET name=:name,image=:image,link=:link,group_id=:group_id WHERE id=:id',
	'promobox_edit'
);
INSERT INTO cf_admin_action (
	id,
	name,
	query,
	params_id
)
VALUES (
	'promobox_add',
	'Добавить promobox',
	'INSERT INTO promobox (name,image,link,group_id) VALUES(:name,:image,:link,:group_id)',
	'promobox_edit'
);
INSERT INTO cf_admin_action (
	id,
	name,
	query
)
VALUES (
	'promobox_del',
	'Удаление',
	'DELETE FROM promobox WHERE id=:id'
);

INSERT INTO cf_admin_view_action (view_id, action_id, sort_order) VALUES ('promobox', 'promobox_edit', 1);
INSERT INTO cf_admin_view_action (view_id, action_id, sort_order) VALUES ('promobox', 'promobox_add',  2);
INSERT INTO cf_admin_view_action (view_id, action_id, sort_order) VALUES ('promobox', 'promobox_del',  3);


INSERT INTO cf_admin_categories (
	id, 
	parent_id, 
	name, 
	list_id,
	sort_order
)
VALUES (
	'promobox',
	NULL,
	'Promobox-ы',
	'promobox',
	10010
);


");

?>
















